import axios from '../utils/axios';

export interface SupervisorDTO {
  id: number;
  name?: string;
  username: string;
  email?: string;
  phone?: string;
  department?: string;
  title?: string;
  status?: string;
  lastLogin?: string;
}

/**
 * Retrieves all supervisors.
 * @returns A promise that resolves to an array of SupervisorDTO objects.
 */
export const getSupervisors = async () => {
  const response = await axios.get('/api/user/supervisors');
  return response.data;
};

/**
 * Retrieves the details of a supervisor.
 * @param supervisorId The ID of the supervisor.
 * @returns A promise that resolves to a SupervisorDTO object.
 */
export const getSupervisorDetail = async (supervisorId: number) => {
  const response = await axios.get(`/api/user/supervisors/${supervisorId}`);
  return response.data;
};

/**
 * Retrieves supervisors by department.
 * @param department The department to filter supervisors by.
 * @returns A promise that resolves to an array of SupervisorDTO objects.
 */
export const getSupervisorsByDepartment = async (department: string) => {
  const response = await axios.get(`/api/user/supervisors/department/${department}`);
  return response.data;
};